﻿using Stardust.Server;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;

namespace WebServer1
{
    public class User
    {
        public int ID { get; set; }

        public string Name { get; set; }
        public string Msg { get; set; }
    }
    public class UserService : IStardustService
    {
        public string Say(string name)
        {
            return "Hello," + name + "!  --from:" + StardustServer.UniqueNodeName;
        }

        public User GetOne(int id = 0)
        {
            User u = new User();
            u.ID = id;
            u.Name = "姓名：" + id.ToString();
            u.Msg = "From " + StardustServer.UniqueNodeName;
            return u;
        }

        public Task<User> Clone(User user)
        {
            return new Task<User>(() =>
            {
                return new User
                {
                    ID = user.ID * 2,
                    Msg = "Clone:" + user.Msg,
                    Name = "Clone:" + user.Name
                };
            });
        }

    }
}